
%%
clear;
close all;

figure;
for i=1:4
% Load data
load(['FX_J_Model',num2str(i+1),'.mat'])
bb = mean(betat_hat, 3);
load('FX_factors.mat')

% Load factor names
futures_name={'AUD','GBP','CAD','EUR','JPY','NZD','NOK','SEK','CHF'};

% Create a figure


    subplot(2, 2, i);

    plot(bb(:,2), bb(:,i+2 ), 'ro', 'MarkerSize', 5); 
    hold on;
    plot(bb(:,2), bb(:,2), 'b:', 'LineWidth', 1);
    

  for j = 1:length(futures_name)
        text(bb(j, 2), bb(j, i+2 ), futures_name{j}, 'FontSize', 8, 'HorizontalAlignment', 'left', 'VerticalAlignment', 'bottom');
  end


    % Linear regression line in black
    p = polyfit(bb(:,2), bb(:,i+2 ), 1);
    yfit = polyval(p, bb(:,2));
    plot(bb(:,2), yfit, 'k-', 'LineWidth', 1.5);  % Black regression line

      xlim([min(bb(:,2)) - 0.05*range(bb(:,2)), max(bb(:,2)) + 0.05*range(bb(:,2))]);
    ylim([min(bb(:,i+2 )) - 0.05*range(bb(:,i+2 )), max(bb(:,i+2 )) + 0.05*range(bb(:,i+2 ))]);


    title([factors_name{2}, ' of M',num2str(i+1)], 'FontSize', 12);
    xlabel('Cont. Beta', 'FontSize', 10);
    ylabel('Jump Beta', 'FontSize', 10);
    %axis tight;
    grid on;


end

% Set the figure background to white for a cleaner look
set(gcf, 'Color', 'w');

